Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate messageCreate off sapphire #328

Merged
merged 2 commits into from
Aug 18, 2022

Conversation

KevinBacabac
Copy link
Contributor

Summary of Changes

Migrates messageCreate logic to a discord.js based file in src/events.

PRs

Resolves #315

Steps to Reproduce

Behaviour is confirmed to be the same with no regressions.

src/bot.ts Show resolved Hide resolved
import { ApplyOptions } from '@sapphire/decorators';
import { container, Listener } from '@sapphire/framework';
import { Message } from 'discord.js';
import { ILogger } from '@sapphire/framework';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep sapphire dependency for logger

@@ -61,7 +59,7 @@ const punishSpammersAndTrolls = async (message: Message): Promise<boolean> => {
error: (err as Error).toString()
});
}
await sendKickEmbed(message, user, reason, isSuccessful);
await sendKickEmbed(client, message, user, reason, isSuccessful);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass in the client as argument rather than using container

if (message.author.bot && message.author.id !== IRC_USER_ID) {
return;
}
export const initMessageCreate = async (client: Client, logger: ILogger, message: Message): Promise<void> => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert class to function

@@ -9,8 +8,13 @@ export const EMBED_COLOUR = '#0099ff';
/*
* Send kick embed
*/
export const sendKickEmbed = async (message: Message, user: User, reason = '', isSuccessful = true): Promise<void> => {
const { client } = container;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use client argument instead of container

Copy link
Collaborator

@mcpenguin mcpenguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nitpick

src/bot.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@Picowchew Picowchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment about if (client.user).

src/bot.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@Picowchew Picowchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@mcpenguin mcpenguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Picowchew Picowchew merged commit 3f1d65e into uwcsc:master Aug 18, 2022
@KevinBacabac KevinBacabac deleted the messageCreate branch August 18, 2022 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate messageCreate listener off Sapphire
4 participants